package main

import (
	"fmt"
	"reflect"
)

//反射的简单使用
func main() {
	//1.获取类型
	num1 := 10
	t1 := reflect.TypeOf(num1)
	fmt.Printf("TypeOf num1 %v \n", t1) //输出int
	var num2 int32 = 10
	fmt.Printf("TypeOf num2 %v \n", reflect.TypeOf(num2)) //输出int32

	stu := Student{
		Name: "路飞",
		Age:  10,
	}
	fmt.Printf("TypeOf stu %v \n", reflect.TypeOf(stu)) //输出main.Student

	fmt.Printf("ValueOf stu %v \n", reflect.ValueOf(stu))
	fmt.Printf("ValueOf num1 %v \n", reflect.ValueOf(num1))
}

type Student struct {
	Name string
	Age  int32
}
